﻿using System;

namespace Microsoft.Popfly.GameCreator.Data
{
    public class PropertyChangeBehaviorInfo : BehaviorInfo
    {
        public enum PropertyChangeType { NOTSET, SETVALUE, ADDVALUE };
        public PropertyChangeType ChangeType { get; private set; }
        [GameXamlProperty]
        public String PropertyName;
        private String m_setValue;
        [GameXamlProperty]
        public String SetValue 
        { 
            get 
            {
                if (ChangeType != PropertyChangeType.SETVALUE) 
                    throw new InvalidOperationException(); 
                return m_setValue; 
            } 
            set 
            { 
                ChangeType = PropertyChangeType.SETVALUE; 
                m_setValue = value; 
            } 
        }

        private String m_addValue;
        [GameXamlProperty]
        public String AddValue 
        { 
            get 
            {
                if (ChangeType != PropertyChangeType.ADDVALUE)
                    throw new InvalidOperationException();
                return m_addValue; 
            } 
            set 
            { 
                ChangeType = PropertyChangeType.ADDVALUE;
                m_addValue = value; 
            } 
        }

        [GameXamlProperty(xamlMappingType = GameXamlProperty.XamlType.complex)]
        public ItemReferenceInfo ItemReference;
    }
}